home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++ CDEV ƒ / UControlPanel.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-24  |  4.0 KB  |  128 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    UControlPanel.h (MPW 3.2)
  3.  *    Copyright ©1991 David Kreindler.  All rights reserved.
  4.  *    
  5.  *    KNOWN BUGS AND SHORTCOMINGS:
  6.  *        [none]
  7.  */
  8.  
  9. #ifndef __UCONTROLPANEL__
  10. #define __UCONTROLPANEL__
  11.  
  12. #ifndef __DIALOGS__
  13. #include <Dialogs.h>
  14. #endif
  15.  
  16. #ifndef __TOOLUTILS__
  17. #include <ToolUtils.h>
  18. #endif
  19.  
  20. #ifndef __UHANDLEOBJECT__
  21. #include <UHandleObject.h>
  22. #endif
  23.  
  24. class TControlPanel: public THandleObject {
  25.     public:
  26.         TControlPanel(DialogPtr, short numItems);
  27.         virtual void DoActivate(EventRecord *, long *cdevValue);                            // activDev
  28.         virtual void DoClear(long *cdevValue);                                                // clearDev
  29.         virtual void DoCopy(long *cdevValue);                                                // copyDev
  30.         virtual void DoCursor(long *cdevValue);                                                // cursorDev
  31.         virtual void DoCut(long *cdevValue);                                                // cutDev
  32.         virtual void DoDeactivate(EventRecord *, long *cdevValue);                            // deActivDev
  33.         virtual void DoHit(short, EventRecord *, long *cdevValue);                            // hitDev; the short is our item number, not the Dialog Manager’s
  34.         virtual void DoInit(long *cdevValue);                                                // initDev
  35.         virtual void DoKeyEvent(EventRecord *, long *cdevValue);                            // keyEvtDev
  36.         virtual void DoMac(long *cdevValue);                                                // macDev
  37.         virtual void DoNull(EventRecord *, long *cdevValue);                                // nulDev
  38.         virtual void DoPaste(long *cdevValue);                                                // pasteDev
  39.         virtual void DoUndo(long *cdevValue);                                                // undoDev
  40.         virtual void DoUpdate(long *cdevValue);                                                // updateDev
  41.     protected:
  42.         operator DialogPtr();                                                                // returns the control panel dialog (is this overloading bad style???)
  43.         short FindDItem(Point thePt);                                                        // overload; wrapper for the return value; returns the actual item id, not -1 as ::
  44.         void GetDItem(short itemNo, short *itemType, Handle *, Rect *);                        // overload; wrapper for itemNo
  45.         short Item(short);                                                                    // returns the dialog manager’s item number; i.e., our item + fNumItems
  46.     private:
  47.         const DialogPtr fDialog;                                                            // the control panel dialog
  48.         const short fNumItems;                                                                // the number of items preceding ours in the control panel’s dialog item list
  49. };
  50.  
  51. void SetCursor(short);                                                                        // overload; sets the cursor to a given CURS resource (this is here because this is example code; it should be in a library)
  52.  
  53. /* —————————————————————————————————— inline definitions —————————————————————————————————— */
  54.  
  55. inline void TControlPanel::DoActivate(EventRecord *, long *) {
  56.     /* empty method */
  57. }
  58.  
  59. inline void TControlPanel::DoClear(long *) {
  60.     DlgDelete(fDialog);
  61. }
  62.  
  63. inline void TControlPanel::DoCopy(long *) {
  64.     DlgCopy(fDialog);
  65. }
  66.  
  67. inline void TControlPanel::DoCut(long *) {
  68.     DlgCut(fDialog);
  69. }
  70.  
  71. inline void TControlPanel::DoDeactivate(EventRecord *, long *) {
  72.     /* empty method */
  73. }
  74.  
  75. inline void TControlPanel::DoHit(short, EventRecord *, long *) {
  76.     /* empty method */
  77. }
  78.  
  79. inline void TControlPanel::DoInit(long *) {
  80.     /* empty method */
  81. }
  82.  
  83. inline void TControlPanel::DoMac(long *cdevValue) {
  84.     *cdevValue = false;                                                                        // this base class does not run under any circumstances (assuming the 'mach' resource permits this to be called)
  85. }
  86.  
  87. inline void TControlPanel::DoNull(EventRecord *, long *) {
  88.     /* empty method */
  89. }
  90.  
  91. inline void TControlPanel::DoPaste(long *) {
  92.     DlgPaste(fDialog);
  93. }
  94.  
  95. inline void TControlPanel::DoUndo(long *) {
  96.     /* empty method */
  97. }
  98.  
  99. inline void TControlPanel::DoUpdate(long *) {
  100.     /* empty method */
  101. }
  102.  
  103. inline short TControlPanel::FindDItem(Point thePt) {
  104.     return ::FindDItem(fDialog, thePt) + fNumItems + 1;
  105. }
  106.  
  107. inline void TControlPanel::GetDItem(short itemNo, short *itemType, Handle *item,
  108.                                     Rect *itemRect) {
  109.     ::GetDItem(fDialog, itemNo + fNumItems, itemType, item, itemRect);
  110. }
  111.  
  112. inline short TControlPanel::Item(short itemNo) {
  113.     return itemNo + fNumItems;
  114. }
  115.  
  116. inline TControlPanel::operator DialogPtr() {
  117.     return fDialog;
  118. }
  119.  
  120. inline void SetCursor(short cursID) {                                                    // accepts CURS resource id
  121.     SetCursor(*GetCursor(cursID));                                                        // !!! we really ought to check for errors here
  122. }
  123.  
  124. inline TControlPanel::TControlPanel(DialogPtr theDialog, short numItems):
  125.     fDialog(theDialog), fNumItems(numItems) {
  126. }
  127.  
  128. #endif